<?php
/*
 * 数组处理类
 * @author andery <andery@foxmail.com>
 * @link http://www.minophp.com/
 * @version $Id: CArray.lib.php 2010-07-08 23:12:10Z andery $
 */
class CArray{
    public static function sysSortArray($ArrayData,$KeyName1,$SortOrder1 = "SORT_ASC",$SortType1 = "SORT_REGULAR") 
    {
        if (!is_array($ArrayData)) {
            return $ArrayData;
        }

        $ArgCount = func_num_args();      

        for ($I = 1;$I < $ArgCount;$I ++) {
            $Arg = func_get_arg($I);
            if (!eregi("SORT",$Arg)) {
                $KeyNameList[] = $Arg;
                $SortRule[] = '$'.$Arg;
            } else {
                $SortRule[] = $Arg;
            }
        }

        foreach ($ArrayData AS $Key => $Info) {
            foreach ($KeyNameList AS $KeyName) {
                ${$KeyName}[$Key] = $Info[$KeyName];
            }
        }

        $EvalString = 'array_multisort('.join(",",$SortRule).',$ArrayData);';
        eval ($EvalString);
        return $ArrayData;
    }
}